/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mundialfp.view.tables;

import mundialfp.view.tables.paisPuntos.TableCustom2CellRender;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * Headers no resizeables-Headers no reordenables-Acepta tipo Imagen-Sin lineas
 * divisorias- Seleccion unica
 *
 * @author pferraz
 */
public class TableCustom2 extends JTable {

    public TableCustom2(int numColumns) {
        super(0, numColumns);
        this.getTableHeader().setResizingAllowed(false);//Hace las columnas no resizeables
        this.getTableHeader().setReorderingAllowed(false);//Hace las columnas no reordenables
        this.setShowGrid(false);//Quita las lineas divisorias
        this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.setFocusable(false);//No podes poner foco
        this.setRowSelectionAllowed(false);//No podes seleccionar
    }

    //  Returning the Class of each column will allow different
    //  renderers to be used based on Class
    @Override
    public Class getColumnClass(int column) {
        return getValueAt(0, column).getClass();
    }

    public void resizeColumns(int cupos) {
        ((DefaultTableCellRenderer) this.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(JLabel.CENTER);

        TableCustom2CellRender renderer = new TableCustom2CellRender(cupos);
        renderer.setHorizontalAlignment(JLabel.CENTER);

        for (int i = 0; i < 11; i++) {

            this.getColumnModel().getColumn(i).setCellRenderer(renderer);

        }
        this.getColumnModel().getColumn(2).setCellRenderer(new TableCustom2CellRender(cupos));

        this.getColumnModel().getColumn(0).setPreferredWidth(30);
        this.getColumnModel().getColumn(2).setPreferredWidth(244);
        this.getColumnModel().getColumn(3).setPreferredWidth(30);
        this.getColumnModel().getColumn(4).setPreferredWidth(30);
        this.getColumnModel().getColumn(5).setPreferredWidth(30);
        this.getColumnModel().getColumn(6).setPreferredWidth(30);
        this.getColumnModel().getColumn(7).setPreferredWidth(30);
        this.getColumnModel().getColumn(8).setPreferredWidth(30);
        this.getColumnModel().getColumn(9).setPreferredWidth(30);
        this.getColumnModel().getColumn(10).setPreferredWidth(50);
    }
}
